function friendTest()
{
	// Run 1 of 3 to test the basic friend flow
	// Become friends, invite then confirm
	//friendInvite("confirm");

	// Deny becoming friend, invite but deny
	//friendInvite("delete");

	// Delete friendship
	//friendDelete();

	// Invite by email, then confirm
	friendInviteByEmail("confirm");
}

function friendInvite(flag:String)
{
	var item=new Object();
	item.type="friendInvite";
	item.param=new Object();
	item.param.memberIdFrom="3";
	item.param.memberIdTo="2";
	item.result=new Object();
	item.result.owner=this;
	item.result.onResult=function(res)
	{
		Packages.log("friendInvite.onResult: "+res.returnObj, "debug");
		if (res.returnObj!=null)
		{
			if (flag=="confirm")
			{
				friendInviteConfirm(res.returnObj.toString());
			} 
			if (flag=="delete") 
			{
				friendInviteDelete(res.returnObj.toString());
			}
		}
	}	
	Packages.services.RemotingCall.rtmpCaller(item);
}

function friendInviteByEmail(flag:String)
{
	var item=new Object();
	item.type="friendInviteByEmail";
	item.param=new Object();
	item.param.memberIdFrom="3";
	item.param.memberToEmail="whb@whb.com";
	item.result=new Object();
	item.result.owner=this;
	item.result.onResult=function(res)
	{
		Packages.log("friendInviteByEmail.onResult: "+res.returnObj, "debug");
		if (res.returnObj!=null)
		{
			if (flag=="confirm")
			{
				friendInviteConfirm(res.returnObj.toString());
			} 
			if (flag=="delete") 
			{
				friendInviteDelete(res.returnObj.toString());
			}
		}
	}	
	Packages.services.RemotingCall.rtmpCaller(item);
}

function friendInviteConfirm(friendConfirmId:String)
{
	var item=new Object();
	item.type="friendInviteConfirm";
	item.param=new Object();
	item.param.friendConfirmId=friendConfirmId;
	item.param.memberIdTo="2";
	item.result=new Object();
	item.result.owner=this;
	item.result.onResult=function(res)
	{
		Packages.log("friendInviteConfirm.onResult: returnCode="+res.returnCode, "debug");
		if (res.returnObj!=null)
		{
		}
	}	
	Packages.services.RemotingCall.rtmpCaller(item);
}

function friendDelete()
{
	var item=new Object();
	item.type="friendDelete";
	item.param=new Object();
	item.param.memberIdFrom="1";
	item.param.memberIdTo="2";
	item.result=new Object();
	item.result.owner=this;
	item.result.onResult=function(res)
	{
		Packages.log("friendDelete.onResult: returnCode="+res.returnCode, "debug");
		if (res.returnObj!=null)
		{
		}
	}	
	Packages.services.RemotingCall.rtmpCaller(item);
}

function friendInviteDelete(friendConfirmId:String)
{
	var item=new Object();
	item.type="friendInviteDelete";
	item.param=new Object();
	item.param.friendConfirmId=friendConfirmId;
	item.param.memberIdTo="2";
	item.result=new Object();
	item.result.owner=this;
	item.result.onResult=function(res)
	{
		Packages.log("friendInviteDelete.onResult: returnCode="+res.returnCode, "debug");
		if (res.returnObj!=null)
		{
		}
	}	
	Packages.services.RemotingCall.rtmpCaller(item);
}